<template>
  <div>
    <button @click="addNum">添加一个数</button>
    <ul>
      <li v-for="(item, index) in arr" :key="index">
        {{ item }}
        <button @click="delNum(index)">删除</button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [],
    };
  },

  created() {},

  methods: {
    addNum() {
      this.arr.push(Math.floor(Math.random() * 100));
    },
    delNum(index) {
      console.log(this.arr[index]);
      this.arr.splice(index, 1);
    },
  },
};
</script>

<style scoped lang="less"></style>
